package com.example.demo.test.nio.bytebuffer;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NettyTest1 {
    public static void main(String[] args) throws IOException {
        FileChannel channel = new FileInputStream("abc.txt").getChannel();
        ByteBuffer byteBuffer=ByteBuffer.allocate(10);
        while (true){
            int read = channel.read(byteBuffer);
            if(read<=-1){
                break;
            }
            byteBuffer.flip();
            while (byteBuffer.hasRemaining()){
                byte aChar = byteBuffer.get();
                System.out.println("a:"+(char)aChar);
            }
            byteBuffer.clear();
        }

    }
}
